package com.zzp.basepresenter.ui.popwindows;

import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;

import com.zzp.basepresenter.R;


/*
 * @author zzp
 * 加载过程弹窗
 * */
public class LoadingProgressPopWindow extends BasePopupWindow {
    private static LoadingProgressPopWindow instance;
    private LinearLayout ll_progress;

    public static LoadingProgressPopWindow getInstance(Activity context) {
        if (instance == null) {
            synchronized (LoadingProgressPopWindow.class) {
                if (instance == null) {
                    instance = new LoadingProgressPopWindow(context);
                }
            }
        }
        return instance;
    }


    public LoadingProgressPopWindow(Activity context) {
        super(context);
    }

    @Override
    public int getResView() {
        return R.layout.layout_pop_loading_progress;
    }

    @Override
    public boolean transparentBackground() {
        return true;
    }

    @Override
    public boolean outTouchNotHide() {
        return true;
    }

    @Override
    public void findViewById(View view) {
        ll_progress = view.findViewById(R.id.ll_progress);
        ll_progress.setOnClickListener(null);
    }

    @Override
    public int setWidth() {
        return (int) context.getResources().getDimension(R.dimen.x80);
    }

    @Override
    public int setHeight() {
        return (int) context.getResources().getDimension(R.dimen.x80);
    }

    @Override
    public int setAnimationStyle() {
        return -1;
    }

    @Override
    public void show(Activity context, View view) {
        this.context = context;
        this.update();
        if (context.isFinishing()) {
            return;
        }
        if (view.getWindowToken() == null) {
            return;
        }
        //以某个控件的x和y的偏移量位置开始显示窗口
        showAtLocation(view, Gravity.CENTER, 0, 0);
    }
}